<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="renderer" content="webkit" />
    <meta name="force-rendering" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>添加银行卡</title>
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    
    <link rel="stylesheet" href="../css/shop.css">
    <link rel="stylesheet" href="../css/weui.min.css">
    <link rel="stylesheet" href="../css/jquery-weui.min.css">
    <script src="../js/jquery-2.1.4.js"></script>
    <script src="../js/jquery-weui.js"></script>
    <script src="../wxJs/utils/contain.js"></script>
    <script src="../wxJs/utils/storage.js"></script>
</head>
<style>
    .model1 {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
        background-color: rgba(0, 0, 0, .6);
        display: none;
    }

    .model1 * {
        box-sizing: border-box
    }

    .model1-contain {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background-color: #fff;
        border-radius: 8px;
        overflow: hidden
    }

    .model1-title {
        width: 100%;
        background-color: #fff;
        border-bottom: 1px solid #d3d3d3;
        text-align: center;
        padding: 15px 0;
        font-weight: 700;
        line-height: 1
    }

    .model1-content {
        border-top: 1px solid #d3d3d3
    }

    .model1-content input[type='password'] {
        padding: 20px;
        text-align: center;
        cursor: none;
        border: none;
        outline: 0;
        font-size: 18px
    }

    .model1-footer {
        display: flex;
        text-align: center;
        border-top: 1px solid #d3d3d3;
        font-size: 16px
    }

    .model1-footer * {
        flex: 1;
        padding: 10px 0;
        cursor: pointer
    }

    .model1-footer .confirm {
        background-color: #ff9c1c;
        color: #fff
    }
</style>
<body>
    <div class="header">
        <a class="haader-left" href="javascript:window.history.go(-1)"><i class="iconfont icon-left"></i></a>
        <div class="haader-content">添加银行卡</div>
        <div class="haader-right">
            <!-- <i class="iconfont icon-riqi"></i>&nbsp; -->
            <!-- <i class="iconfont icon-shaixuan"></i> -->
        </div>
    </div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">开户名</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" placeholder="开户名" id="accountName" >
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd"><label class="weui-label">开户银行</label></div>
            <div class="weui-cell__bd" >
                <select class="weui-select" id="bankCode" >
                    <option value="1002">工商银行</option>
                    <option value="1005">农业银行</option>
                    <option value="1003">建设银行</option>
                    <option value="1026">中国银行</option>
                    <option value="1020">交通银行</option>
                    <option value="1001">招商银行</option>
                    <option value="1066">邮储银行</option>
                    <option value="1006">民生银行</option>
                    <option value="1010">平安银行</option>
                    <option value="1021">中信银行</option>
                    <option value="1004">浦发银行</option>
                    <option value="1009">兴业银行</option>
                    <option value="1022">光大银行</option>
                    <option value="1027">广发银行</option>
                    <option value="1025">华夏银行</option>
                    <option value="1056">宁波银行</option>
                    <option value="4836">北京银行</option>
                    <option value="1024">上海银行</option>
                    <option value="1054">南京银行</option>
                    <option value="4755">长子县融汇村镇银行	</option>
                    <option value="4216">长沙银行  </option>
                    <option value="4051">浙江泰隆商业银行 </option>
                    <option value="4753">中原银行 </option>
                    <option value="4761">企业银行（中国）</option>
                    <option value="4036">顺德农商银行</option>
                    <option value="4752">衡水银行</option>
                    <option value="4756">长治银行</option>
                    <option value="4767">大同银行</option>
                    <option value="4115">河南省农村信用社	</option>
                    <option value="4150">宁夏黄河农村商业银行 </option>
                    <option value="4156">山西省农村信用社 </option>
                    <option value="4166">安徽省农村信用社 </option>
                    <option value="4157">甘肃省农村信用社	</option>
                    <option value="4153">天津农村商业银行   </option>
                    <option value="4113">广西壮族自治区农村信用社	   </option>
                    <option value="4108">陕西省农村信用社	   </option>
                    <option value="4076">深圳农村商业银行	  </option>
                    <option value="4052">宁波鄞州农村商业银行	 </option>
                    <option value="4764">浙江省农村信用社联合社	  </option>
                    <option value="4217">江苏省农村信用社联合社  </option>
                    <option value="4072">江苏紫金农村商业银行股份有限公司	 </option>
                    <option value="4769">北京中关村银行股份有限公司	 </option>
                    <option value="4778">星展银行（中国）有限公司	  </option>
                    <option value="4766">枣庄银行股份有限公司	 </option>
                    <option value="4758">海口联合农村商业银行股份有限公司</option>
                    <option value="4763">南洋商业银行（中国）有限公司	</option>
                </select>
                <!-- <i class="iconfont icon-right f-r f12"></i> -->
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">卡号</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="number" placeholder="持卡人本人银行卡号" id="bankNum" >
            </div>
        </div>

    </div>

    <div class="btn-contain">
        <a href="javascript:;" class="weui-btn weui-btn_primary mt10">绑定</a>
    </div>
    <div class="model1">
        <div class="model1-contain">
            <div class="model1-title">支付密码</div>
            <div class="model1-content">
                <input id="code" type="password" placeholder="请输入支付密码" maxlength="6" oninput="setNumType(this)">
            </div>
            <div class="model1-footer">
                <div class="cancel">取消</div>
                <div class="confirm">确认</div>
            </div>
        </div>
    </div>
</body>
    <script>
        var shopId  = GetQueryString("shopId")
        var sysUserId
        if (!shopId){
            window.history.back(-1);
        }else {
           $.post(getWeiContextPath()+"/wx/shop/selectShopById",{shopId:shopId},function (res) {
               sysUserId= res.data.wxUserId
           })
        }
        var bankCode
        var bankName
        var accountName
        var bankNum
        $(".mt10").on("click",function () {
            bankCode= $('#bankCode').val()
            accountName= $('#accountName').val()
            bankName= $("#bankCode option:selected").text();
             bankNum= $('#bankNum').val()

            if (!accountName){
                $.toast("开户名未填写", "forbidden");
                return false;
            }
            if (!checkCard(bankNum)){
                $.toast("卡号有误,请核对", "forbidden");
                return false;
            }
            userInfo =getUserInfo(sysUserId)
            if (!userInfo.payNumber) {
                $.toast("请先设置支付密码", "forbidden")
                return false;
            } else {
                $('.model1').show()
            }

        })
        
        /*验证银行卡号*/
        function checkCard(cardNum) {
            var regExp = /^([1-9]{1})(\d{15}|\d{18})$/;
            return regExp.test(cardNum)
        };


        $(".cancel").on('click', function () {
            $('.model1').hide()
        })

        /*弹出输入框,判断输入字符返回*/
        $(".confirm").on('click', function () {
            var code = $('#code').val()
            if (!code){
                $.toast("请输入密码", "forbidden")
                return false;
            }
            if (code == userInfo.payNumber) {
                $.post(getWeiContextPath()+"/wx/shop/addShopBank",{accountName:accountName,bankCode:bankCode,bankNum:bankNum,bankName:bankName,belongId:shopId,belongType:1},function (res) {
                    $.toast("添加成功",function () {
                        window.location.replace("bank_list.html?shopId="+shopId)
                    });
                })
            } else {
                $.toast("密码错误", "forbidden")
            }
        })

        /*只能输入数字*/
        function setNumType(_this) {
            var num = $(_this).val()
            $(_this).val(num.replace(/[^\d]/g,''))

        }

    </script>
</html>